package com.dynaBlaster.gameElements;

import com.dynaBlaster.BoardView;
import com.dynaBlaster.DynaView;
import com.dynaBlaster.Point;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;

public abstract class Artefact {

	Bitmap bitmap;
	/**
	 * posistiom i.e. field coord on the bord, not absolute!!
	 */
	Point pos;
	protected DynaView board;

	public Artefact(Point pos, DynaView board) {
		this.board = board;
		this.pos = pos;
	}

	private Artefact() {
	};

	void loadImg(Drawable drawable) {

		Bitmap bmp = Bitmap.createBitmap(BoardView.mTileSize, BoardView.mTileSize, Bitmap.Config.ARGB_8888);
		Canvas canvasBmp = new Canvas(bmp);
		drawable.setBounds(0, 0, BoardView.mTileSize, BoardView.mTileSize);
		drawable.draw(canvasBmp);
		bitmap = bmp;

	}

	public void draw(Canvas canvas) {
		Point absPos = BoardView.getAbsCoord(pos);

		canvas.drawBitmap(bitmap, absPos.x, absPos.y, new Paint());
	}

}
